package com.huilian.iotbox.admin.quartz.job;

import com.huilian.iotbox.admin.service.StatsStoreDeviceTypeService;
import com.huilian.iotbox.admin.service.StatsUserDeviceTypeService;
import com.huilian.iotbox.data.utils.DateTimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import javax.annotation.Resource;

/**
 * @author: loong
 * @create: 2023-04-22 14:22
 **/
@Slf4j
public class StatsDayUserAndStoreDeviceTypeJob implements BaseJob {
    @Resource
    private StatsUserDeviceTypeService statsUserDeviceTypeService;
    @Resource
    private StatsStoreDeviceTypeService statsStoreDeviceTypeService;

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        log.info("--------------定时任务 按设备类型统计 统计开始 时间{}---------------", DateTimeUtils.currTime());
        try {
            statsStoreDeviceTypeService.statsYesterdayStoreDeviceType();
            statsUserDeviceTypeService.statsYesterdayUserDeviceType();
        } catch (Exception e) {
            log.error("按设备类型统计失败！" + e.getMessage());
        }

        log.info("--------------定时任务 按设备类型统计 统计结束 end时间{}---------------", DateTimeUtils.currTime());
    }
}
